function flatten(arr) {
    var result = []; // es5
    for (let i = 0, len = arr.length; i<len; i++) {
        if (Array.isArray(arr[i])) { // 后期之秀
            result = result.concat(flatten(arr[i])) // 递归
        } else {
            result.push(arr[i])
        }
    }
    return result;
}

console.log( flatten([1,2,[4,[3]]]) )